<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css"
	href="static/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="static/easyui/themes/icon.css">

<script type="text/javascript" src="static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
		//换验证图
		function change(){
			$("#captcha").attr("src","captcha/change?x="+Math.random());
		}
		
	$(document).ready(function() {
		if('${loginerr}'=="notok"){
		$('#userpasswordmessage').html($("<font id='eee' style='color:red;'>错误错误</font>"));}
		if('${loginerr}'=="nouser"){
		$('#userpasswordmessage').html($("<font id='eee' style='color:red;'>账号或密码错误</font>"));}
		
		
		//每次键盘抬起验证
		$('#captchatxt').keyup(function(){
			if($("#captchatxt").val().length!=5){
				var oldcaptchaboxmsg="";
				oldcaptchaboxmsg=$("<font style='color:red;'>验证码错误</font>");
				$('#captchamessage').html(oldcaptchaboxmsg);
			}else{
			$.ajax({
				type:"post",
				url:"captcha/checks",
				data:{vCode:$("#captchatxt").val()},
				dataType:"text",
				success: function(msg){
					var captchaboxmsg="";
					if(msg=="ok"){
						captchaboxmsg=$("<font id='eee' style='color:green;'>恭喜你，验证码正确</font>");
					}else{
						captchaboxmsg=$("<font id='eee' style='color:red;'>验证码错误</font>");
					}
					$('#captchamessage').html(captchaboxmsg);
				},
			});
			}
		}); 
		
		$('#p').dialog({    
		    title: '登入窗口',    
		    width: 500,    
		    height: 300,    
		    closed: false,    
		    cache: false,    
		    modal: true,
		    buttons : [ {
				text : '登 录',
				handler : function() {
					//登录代码
					if($('#ff').form('validate')){
							$('#ff').submit();
					}
				}
			}]
		});
		
		
	});
</script>
</head>
<body>
	<div id="p" style="padding: 10px;">
		<form id="ff" action="login" method="post" >
			<div>
				<label for="usercode">账&nbsp;&nbsp;&nbsp;号</label> 
				<input id="usercode" name="usercode" class="easyui-validatebox" data-options="validType:'length[6,20]'"><span id="usercodemessage" ></span> 
			</div><br>
			<div>
				<label for="userpassword">密&nbsp;&nbsp;&nbsp;码</label>
				<input id="userpassword" name="userpassword" type="password" class="easyui-validatebox" data-options="validType:'length[6,20]'"><span id="userpasswordmessage" ></span>  
			</div><br>
			<div id="captchabox">
				<label for="captcha">验证码</label>
				<input id="captchatxt" name="captchatxt" /><span id="captchamessage" ></span> 
			</div><br>
				 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img id="captcha" alt="点我换一张" src="captcha/change" title="点我换一张" onclick="change()" ><br>
		</form>
	</div>
</body>
</html>